\hypertarget{class_r_t_o_s_1_1pool}{\section{R\-T\-O\-S\-:\-:pool$<$ T $>$ Class Template Reference}
\label{class_r_t_o_s_1_1pool}\index{R\-T\-O\-S\-::pool$<$ T $>$@{R\-T\-O\-S\-::pool$<$ T $>$}}
}


place to store and rectrieve data, no built-\/in synchronisation  




{\ttfamily \#include $<$p\-R\-T\-O\-S.\-h$>$}

Inheritance diagram for R\-T\-O\-S\-:\-:pool$<$ T $>$\-:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{class_r_t_o_s_1_1pool}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{class_r_t_o_s_1_1pool_a34dfd08a46f1fd274f1692469eebaf36}{pool} (const char $\ast$name=\char`\"{}\char`\"{})
\begin{DoxyCompactList}\small\item\em construct a pool, specify its name (for debgging only) \end{DoxyCompactList}\item 
void \hyperlink{class_r_t_o_s_1_1pool_a2bd2a2bfb99d74c8b123de344698ff53}{write} (T item)
\begin{DoxyCompactList}\small\item\em atomic write operation on a pool \end{DoxyCompactList}\item 
T \hyperlink{class_r_t_o_s_1_1pool_a0ef6382b71ae141cf38f477c8bfea325}{read} (void)
\begin{DoxyCompactList}\small\item\em atomic read operation on a pool \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Additional Inherited Members}


\subsection{Detailed Description}
\subsubsection*{template$<$class T$>$class R\-T\-O\-S\-::pool$<$ T $>$}

place to store and rectrieve data, no built-\/in synchronisation 

\begin{DoxyVerb}  A (communication) pool is a template class that stores a single value.
  It supports the read and write operations, which are guaranteed to be 
  atomic. (On a non-preemptive RTOS every assignment is atomic, 
  but the pool template is still usefull to make it explicit that
  data is transferred between tasks.) 
  A pool is just a variable. 

  The example below demonstrates the use of a pool to 
  maintain a seconds-since-startup counter. 
  Note that the call RTOS::runtime() returns the time elapsed since 
  startup, so there is no need to maintain a 
  seconds-since-startup this way yourself.

  @code 
\end{DoxyVerb}


pool$<$ unsigned int $>$ seconds;

void show\-\_\-time( void )\{ unsigned int n = seconds.\-read(); std\-::cout $<$$<$ ( seconds / 60 ) \% 60 $<$$<$ \char`\"{}\-:\char`\"{} $<$$<$ seconds \% 60; \}

class seconds\-\_\-counter\-\_\-class \-: public periodic\-\_\-task \{ seconds\-\_\-counter( void )\{ periodic\-\_\-task\-::periodic\-\_\-task( \char`\"{}sec-\/counter\char`\"{}, 10, 1000 M\-S ); seconds.\-write( 0 ); \} void main( void )\{ for(;;)\{ (void)wait(); // only one thing to wait for seconds.\-write( seconds.\-read() + 1 ); \} \} \}

seconds\-\_\-counter\-\_\-class seconds\-\_\-counter;

\subsection{Constructor \& Destructor Documentation}
\hypertarget{class_r_t_o_s_1_1pool_a34dfd08a46f1fd274f1692469eebaf36}{\index{R\-T\-O\-S\-::pool@{R\-T\-O\-S\-::pool}!pool@{pool}}
\index{pool@{pool}!RTOS::pool@{R\-T\-O\-S\-::pool}}
\subsubsection[{pool}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T$>$ {\bf R\-T\-O\-S\-::pool}$<$ T $>$\-::{\bf pool} (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{name = {\ttfamily \char`\"{}\char`\"{}}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{class_r_t_o_s_1_1pool_a34dfd08a46f1fd274f1692469eebaf36}


construct a pool, specify its name (for debgging only) 

Use it to make (global) variables use for communication between tasks explicit.

The template argument T must be a class that has a non-\/arguments constructor and supports assignment. 

\subsection{Member Function Documentation}
\hypertarget{class_r_t_o_s_1_1pool_a0ef6382b71ae141cf38f477c8bfea325}{\index{R\-T\-O\-S\-::pool@{R\-T\-O\-S\-::pool}!read@{read}}
\index{read@{read}!RTOS::pool@{R\-T\-O\-S\-::pool}}
\subsubsection[{read}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T$>$ T {\bf R\-T\-O\-S\-::pool}$<$ T $>$\-::read (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{class_r_t_o_s_1_1pool_a0ef6382b71ae141cf38f477c8bfea325}


atomic read operation on a pool 

A read opeartion returns the most recently written data.

In the context of co-\/operative multitasking a read of write operation on anything is always atomic, unless the implementation of that operating somehow invokes the \hyperlink{class_r_t_o_s}{R\-T\-O\-S}. But for clearness it is a good idea to implement such task-\/global data as pools.  \hypertarget{class_r_t_o_s_1_1pool_a2bd2a2bfb99d74c8b123de344698ff53}{\index{R\-T\-O\-S\-::pool@{R\-T\-O\-S\-::pool}!write@{write}}
\index{write@{write}!RTOS::pool@{R\-T\-O\-S\-::pool}}
\subsubsection[{write}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class T$>$ void {\bf R\-T\-O\-S\-::pool}$<$ T $>$\-::write (
\begin{DoxyParamCaption}
\item[{T}]{item}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{class_r_t_o_s_1_1pool_a2bd2a2bfb99d74c8b123de344698ff53}


atomic write operation on a pool 

A read opeartion returns the most recently written data.

In the context of co-\/operative multitasking a read of write operation on anything is always atomic, unless the implementation of that operating somehow invokes the \hyperlink{class_r_t_o_s}{R\-T\-O\-S}. But for clearness it is a good idea to implement such task-\/global data as pools. 

The documentation for this class was generated from the following file\-:\begin{DoxyCompactItemize}
\item 
p\-R\-T\-O\-S.\-h\end{DoxyCompactItemize}
